<?php
// include function files for this application
require_once('/home/domains/uny-con.com/public_html/uny-con_fns.php');
if (!session_id()) { session_start(); }


//Control variables
//this variable sets the number we are checking
$n = $_GET['num'];

//This is an admin only script so first lets check to make sure the user is valid and an admin. then we can do toher stuff.

if (!check_valid_user() || ($_SESSION['admin'] != 't')) {
	do_html_header('Unauthorized access', staysmall, $uny);
	echo 'You are not logged in or are not authorized to view this page. Please move along.';
	print_brs(6);
	do_html_footer(news);
	exit;
	}

	do_html_header('Listing of GMs who are running $n hours', staysmall, $uny);

if (!($conn = db_connect())) return false;

$pgattendee_id = pg_query("SELECT gm_id, sum FROM num_of_hours_run WHERE sum >= '$n hours' ORDER BY last_name ASC, first_name ASC");

echo "<h1>GMs who are running $n or more hours.</h1>\n";
echo "\t<ul class=\"plainul\">\n";
while ($row = pg_fetch_array($pgattendee_id)) {

	//get the events the user is running
		$userinfo = get_user_info($row['gm_id']);
		echo "\t\t<li class=\"infolist\"><a href=\"attendee_home.php?attendee_id=".$userinfo["attendee_id"]."\">".$userinfo["first_name"].' '.$userinfo["last_name"]."</a>"." ".$row['sum']."</li>\n";
		if (isset($email_list)) $email_list = $email_list.', '.$userinfo["email_addr"];
		else $email_list = $userinfo["email_addr"];
	}
echo '</ul>';
echo "You can also <a href=\"mailto:$email_list\">email</a> all the above gm's";

do_html_footer(news);